package com.example.demo.controller;

import com.example.demo.entity.Blog;
import com.example.demo.service.BlogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhz
 * @since 2025-04-01
 */
@RestController
@RequestMapping("/blog")
public class BlogController {
    @Autowired
    private BlogService blogService; // 依赖注入 Service

    /**
     * 根据用户ID查询
     * @param blogId ID（通过URL路径传递）
     * @return blog信息
     */
    @GetMapping("/{blogId}")
    public Blog getBlogById(@PathVariable Long blogId) {
        return blogService.getById(blogId);
    }

}
